package com.guochenglang.www.service;

import com.guochenglang.www.web.result.Result;
import org.apache.commons.fileupload.FileItem;

import javax.servlet.http.HttpServletRequest;
import java.sql.SQLException;

/**
 * @author GuoChenglang
 */
public interface FileService {
    /**
     * 获取文章id
     *
     * @param item 前端获取的非文件的item字段
     * @return 文章的id
     */
    int processFormField(FileItem item);

    /**
     * 上传附件到本地文件
     *
     * @param fileItem 含附件信息的item字段
     * @param request  request
     * @return 执行结果
     */
    Result processFileUpload(FileItem fileItem, HttpServletRequest request);

    /**
     * 上传文件与article绑定
     *
     * @param articleId 文章id
     * @param url       附件在本地的连接
     * @return 添加的主键
     * @throws SQLException           sql异常
     * @throws InterruptedException   断点异常
     * @throws IllegalAccessException 非法访问异常
     */
    int articleImageUpload(Integer articleId, String url) throws SQLException, InterruptedException, IllegalAccessException;
}
